<?php
namespace Home\Controller;

use Think\Controller;

class UserController extends CommonController
{

    public function frozen(){
        $id=gpc('id');
        M('user')->where(array('UE_ID'=>$id))->save(array('UE_status'=>1));
        $this->success('冻结成功！');
    }

    public function reuser(){
        $listuser=M('user')->limit(1,5000)->select();
        dump(count($listuser));
        $str_date='2016-06-28 00:00:00';
        echo "<table style='border: solid'>";
        foreach ($listuser as $info){

            $where=null;
            $where['UG_getTime']=array('gt',$str_date);
            $where['UG_account']=$info['ue_account'];
            $where['UG_dataType']='xtzs';
            $list=M('userget')->where($where)->select();
            $count=count($list);

            $sum=M('userget')->where($where)->sum('ug_money');
            if($count>1 && $sum>0){
                echo "<tr><td>" . $info['ue_account']. "</td><td>" . $sum  . "</td></tr> " ;
                
            }
        }
        echo "</table>";

    }

    public function search_zj(){


        $username=gpc('user');
        $username=trim($username);
        $User = M('userget'); // 實例化User對象


        if ($User <> '') {
            $map['UG_account'] = $username;
        }

        $map['UG_dataType'] = 'xtzs';

        $count = $User->where($map)->count(); // 查詢滿足要求的總記錄數
        //$page = new \Think\Page ( $count, 3 ); // 實例化分頁類 傳入總記錄數和每頁顯示的記錄數(25)

        $p = getpage($count, 20);

        $list = $User->where($map)->order('UG_ID DESC')->limit($p->firstRow, $p->listRows)->select();
        $this->assign('list', $list); // 賦值數據集
        $this->assign('page', $p->show()); // 賦值分頁輸出

        $this->display('index/jbzs');
    }
//    public function pre_deposit()
//    {
//        $this->settings('pre_deposit');
//    }
}